package leet.ku._67;

public class Solution {
    public String addBinary(String a, String b) {
    	StringBuilder sb = new StringBuilder();
    	int p = 0;
    	for (int i = 0; i < a.length() || i < b.length(); i++) {
    		if (i < a.length())
    			p += a.charAt(a.length() - i - 1) - '0';
    		if (i < b.length())
    			p += b.charAt(b.length() - i - 1) - '0';
    		sb.append(p & 1);
    		p >>= 1;
    	}
    	if (p > 0)
    		sb.append(p);
    	return sb.reverse().toString();
    }
}